// subtool/pages/painclass/index/index.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    navList:[],
    list:[]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    let that =this
    that.xInit()
    that.getcourse()
  },
  onShow() {

  },
  xInit:function(){
    let that =this
    wx.cloud.callFunction({
      name: 'pain_class',
      data: {
        action: "get_classification"
      }
    }).then(res => {
      that.setData({
        navList:res.result
      })
    })

    
  },
  getcourse:function(){
    let that =this
    wx.cloud.callFunction({
      name: 'pain_class',
      data: {
        action: "get_required_course"
      }
     }).then(res => {
      that.setData({
        list:res.result
      })
     })
  },
  getList:function(id){
    let that =this
    wx.cloud.callFunction({
      name: 'pain_class',
      data: {
        action: "get_content_by_classification",
        classification_id:id
      }
    }).then(res => {
        that.setData({
          list:res.result
        })
    })
  },
  changeType:function(e){
    let id = e.currentTarget.dataset.id
    this.getList(id)
  },
  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})